<?php
namespace Admin\Controller;
class StockController extends BaseController{
    function index(){
        $pid=I('get.id');
        if(IS_AJAX){
            
            $data=M('stock')->select();
            echo json_encode($data);
            //$this->ajaxReturn($data);
            die;
        }
        $prow=M('product')->where(array('id'=>$pid))->find();
        
        $attr_arr=M('attr')->where(array('cid'=>$prow['cid'],'isbuy'=>1))->select();
       //print_r($attr_arr);die;
       foreach ($attr_arr as &$v){
           if($v['isselect']){
               $v['options']=explode('|', $v['options']);
           }
       }
       $this->assign('attr',$attr_arr);
        $this->assign('title',$prow['title']);
        $this->display();
    }
    function add(){
        echo I('get.id');
        //dump($_POST);
    }
    
}